<?php

add_action('init','of_options');

if (!function_exists('of_options'))
{
	function of_options()
	{
		//Access the WordPress Categories via an Array
		$of_categories 		= array();  
		$of_categories_obj 	= get_categories('hide_empty=0');
		foreach ($of_categories_obj as $of_cat) {
		    $of_categories[$of_cat->cat_ID] = $of_cat->cat_name;}
		$categories_tmp 	= array_unshift($of_categories, "Select a category:");    
	       
		//Access the WordPress Pages via an Array
		$of_pages 			= array();
		$of_pages_obj 		= get_pages('sort_column=post_parent,menu_order');    
		foreach ($of_pages_obj as $of_page) {
		    $of_pages[$of_page->ID] = $of_page->post_name; }
		$of_pages_tmp 		= array_unshift($of_pages, "Select a page:");       
	
		//Testing 
		$of_options_select 	= array("one","two","three","four","five"); 
		$of_options_radio 	= array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five");
		
		//Sample Homepage blocks for the layout manager (sorter)
		$of_options_homepage_blocks = array
		( 
			"disabled" => array (
				"placebo" 		=> "placebo", //REQUIRED!
				"block_one"		=> "Block One",
				"block_two"		=> "Block Two",
				"block_three"	=> "Block Three",
			), 
			"enabled" => array (
				"placebo" 		=> "placebo", //REQUIRED!
				"block_four"	=> "Block Four",
			),
		);

		$zon_option_home_layout = array
		( 
			"disabled" => array (
				"random"		=> "Random properties",
				"lastest"		=> "Lastest properties",
				"popular"	=> "Popular properties",
			), 
			"enabled" => array (
				"featured" 		=> "Featured properties", //REQUIRED!
				"recent"	=> "Recent properties",
			),
		);


		//Stylesheets Reader
		$alt_stylesheet_path = LAYOUT_PATH;
		$alt_stylesheets = array();
		
		if ( is_dir($alt_stylesheet_path) ) 
		{
		    if ($alt_stylesheet_dir = opendir($alt_stylesheet_path) ) 
		    { 
		        while ( ($alt_stylesheet_file = readdir($alt_stylesheet_dir)) !== false ) 
		        {
		            if(stristr($alt_stylesheet_file, ".css") !== false)
		            {
		                $alt_stylesheets[] = $alt_stylesheet_file;
		            }
		        }    
		    }
		}


		//Background Images Reader
		$bg_images_path = get_stylesheet_directory(). '/images/bg/'; // change this to where you store your bg images
		$bg_images_url = get_template_directory_uri().'/images/bg/'; // change this to where you store your bg images
		$bg_images = array();
		
		if ( is_dir($bg_images_path) ) {
		    if ($bg_images_dir = opendir($bg_images_path) ) { 
		        while ( ($bg_images_file = readdir($bg_images_dir)) !== false ) {
		            if(stristr($bg_images_file, ".png") !== false || stristr($bg_images_file, ".jpg") !== false) {
		            	natsort($bg_images); //Sorts the array into a natural order
		                $bg_images[] = $bg_images_url . $bg_images_file;
		            }
		        }    
		    }
		}
		

		/* Zonthemes Add */
			// Add list properties new
				$url =  ADMIN_DIR . 'assets/images/';
				$of_properties_news=array('features'=>'Features','most_recent'=>'Most recent','popular'=>'Popular');
				$of_properties_new_tmp = array_unshift($of_properties_news, "Select a group:");  	
				$of_properties_layout_select = array("one"=>$url . '1col.png',"two"=>$url . '2cr.png',"three"=>$url . '2cl.png',"four"=>$url . '3cm.png'); 
				$of_properties_layout_select_tmp=$of_properties_layout_select;  
				
			//
		
		/* End */
		

		/*-----------------------------------------------------------------------------------*/
		/* TO DO: Add options/functions that use these */
		/*-----------------------------------------------------------------------------------*/
		
		//More Options
		$uploads_arr 		= wp_upload_dir();
		$all_uploads_path 	= $uploads_arr['path'];
		$all_uploads 		= get_option('of_uploads');
		$other_entries 		= array("Select a number:","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");
		$body_repeat 		= array("no-repeat","repeat-x","repeat-y","repeat");
		$body_pos 			= array("top left","top center","top right","center left","center center","center right","bottom left","bottom center","bottom right");
		
		// Image Alignment radio box
		$of_options_thumb_align = array("alignleft" => "Left","alignright" => "Right","aligncenter" => "Center"); 
		
		// Image Links to Options
		$of_options_image_link_to = array("image" => "The Image","post" => "The Post"); 


/*-----------------------------------------------------------------------------------*/
/* The Options Array */
/*-----------------------------------------------------------------------------------*/

// Set the Options Array
global $of_options;
$of_options = array();

$of_options[] = array( 	"name" 		=> "General Settings",
						"type" 		=> "heading"
				);
$of_options[] = array( 	"name" 		=> "Upload logo",
						"desc" 		=> "Upload images logo",
						"id" 		=> "zon_option_logo",
						"std" 		=> "",
						"type" 		=> "upload"
				);
$of_options[] = array( 	"name" 		=> "Upload Favicon icon",
						"desc" 		=> "Upload Favicon icon",
						"id" 		=> "zon_option_favicon",
						"std" 		=> "",
						"type" 		=> "upload"
				);
$of_options[] = array( 	"name" 		=> "Header code",
						"desc" 		=> "insert header code",
						"id" 		=> "zon_option_ger_header",
						"std" 		=> "",
						"type" 		=> "textarea"
				);
$of_options[] = array( 	"name" 		=> "Tracking Code",
						"desc" 		=> "Paste your Google Analytics (or other) tracking code here. This will be added into the footer template of your theme.",
						"id" 		=> "zon_option_analytic",
						"std" 		=> "",
						"type" 		=> "textarea"
				);

$of_options[] = array( 	"name" 		=> "Home Settings",
						"type" 		=> "heading"
				);
//home start
$of_options[] = array( 	"name" 		=> "Choose home style",
						"desc" 		=> "Select home style",
						"id" 		=> "zon_option_home_style",
						"std" 		=> "",
						"type" 		=> "select",
						"options" 	=> array('Map header','Slider header')
				);

$url =  ADMIN_DIR . 'assets/images/';
$of_options[] = array( 	"name" 		=> "Main Layout",
						"desc" 		=> "Select main content and sidebar alignment. Choose between 1, 2 or 3 column layout.",
						"id" 		=> "zon_option_home_layout",
						"std" 		=> "left-sidebar",
						"type" 		=> "images",
						"options" 	=> array(
							'full-width' 	=> $url . '1col.png',
							'right-sidebar' 	=> $url . '2cr.png',
							'left-sidebar' 	=> $url . '2cl.png'
						)
				);

$of_options[] = array( 	"name" 		=> "Show/hide description home page",
						"desc" 		=> "Switch OFF with hidden options. ;)",
						"id" 		=> "zon_option_desc_home",
						"std" 		=> 0,
						"folds"		=> 1,
						"type" 		=> "switch"
				);
				
$of_options[] = array( 	"name" 		=> "Home description title",
						"desc" 		=> "This is text title show in home",
						"id" 		=> "zon_option_desc_home_title",
						"std" 		=> "",
						"fold" 		=> "zon_option_desc_home", /* the switch hook */
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Home description",
						"desc" 		=> "",
						"id" 		=> "zon_option_desc_home_desc",
						"fold" 		=> "zon_option_desc_home",
						"std" 		=> "",
						"type" 		=> "textarea"
				);

$of_options[] = array( 	"name" 		=> "Homepage Layout Manager",
						"desc" 		=> "Organize how you want the layout to appear on the homepage",
						"id" 		=> "homepage_blocks",
						"std" 		=> $zon_option_home_layout,
						"type" 		=> "sorter"
				);

$of_options[] = array( 	"name" 		=> "Enable / Disable Features",
						"desc" 		=> "Switch Enable show content",
						"id" 		=> "zon_option_features",
						"std" 		=> 0,
						"folds"		=> 1,
						"type" 		=> "switch",
						"on"		=> "Enable",
						"off"  		=> "Disable"
				);

$of_options[] = array( 	"name" 		=> "Show / hide Features",
						"desc" 		=> "Switch show content",
						"id" 		=> "zon_option_features_show",
						"std" 		=> "",
						"fold"		=> "zon_option_features",
						"type" 		=> "switch",
						"on"        => "Show",
						"off" 		=> "Hide"
				);

$of_options[] = array( 	"name" 		=> "Theme Features Title",
						"desc" 		=> "This is text title show in home",
						"id" 		=> "zon_option_features_title",
						"std" 		=> "",
						"fold" 		=> "zon_option_features", /* the switch hook */
						"type" 		=> "text"
				);


//end home

//pricing settings
$of_options[] = array( 	"name" 		=> "Pricing Settings",
						"type" 		=> "heading"
				);
$of_options[] = array( 	"name" 		=> "Currency symbol:",
						"desc" 		=> "Default : '$'",
						"id" 		=> "zon_option_symbol",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Currency symbol position:",
						"desc" 		=> "Default : 'right'",
						"id" 		=> "zon_option_symbol_positions",
						"std" 		=> "",
						"type" 		=> "select",
						"options" 	=> array('In front of sum (eg: $50)','After the sum (eg: 50$)')
				);
$of_options[] = array( 	"name" 		=> "Decimals sum separator:",
						"desc" 		=> "Default : '.'",
						"id" 		=> "zon_option_symbol_decimals",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Thousands sum separator:",
						"desc" 		=> "Default : ','",
						"id" 		=> "zon_option_symbol_thousand",
						"type" 		=> "text"
				);
//end pricing settings.

//start size unit
$of_options[] = array( 	"name" 		=> "Unit of measurement Settings",
						"type" 		=> "heading"
				);
$of_options[] = array( 	"name" 		=> "Select unit of measurement:",
						"desc" 		=> "Default : 'sqft'",
						"id" 		=> "zon_option_symbol_positions",
						"std" 		=> "",
						"type" 		=> "select",
						"options" 	=> array('sq ft','m2')
				);

//Zonthemes add
$assets_dir =  ADMIN_DIR . 'assets';
$of_options[] = array( 	"name" 		=> "Group Properties",
						"desc" 		=> "Choose group properties show homepage <div><span class='button' id='add_property_group' rel='".$assets_dir."'> Add Group </span></div>",
						"id" 		=> "custom_properties_group",
						"std" 		=> array(array('group' => $of_properties_new_tmp,'layout' => $of_properties_layout_select_tmp,'num'=>'5')),
						"type" 		=> "group_properties"
				);
//End Zonthemes add

//breadcrumb setting.

$of_options[] = array( 	"name" 		=> "Breadcrumb Settings",
						"type" 		=> "heading"
				);
$of_options[] = array( 	"name" 		=> "Breadcrumb Separator",
						"desc" 		=> "",
						"id" 		=> "zon_option_bread_sep",
						"std" 		=> "   /   ",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Home breadcrumb",
						"desc" 		=> "",
						"id" 		=> "zon_option_bread_home",
						"std" 		=> "Home",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Category breadcrumb",
						"desc" 		=> "%s is current category",
						"id" 		=> "zon_option_bread_cate",
						"std" 		=> "Archive by Category : %s",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Search breadcrumb",
						"desc" 		=> "%s is current key search",
						"id" 		=> "zon_option_bread_search",
						"std" 		=> "Search Results for : %s",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Tags breadcrumb",
						"desc" 		=> "%s is current tag",
						"id" 		=> "zon_option_bread_tag",
						"std" 		=> "Posts Tagged : %s",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Author breadcrumb",
						"desc" 		=> "%s is current author",
						"id" 		=> "zon_option_bread_author",
						"std" 		=> "Articles Posted by : %s",
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Error page breadcrumb",
						"desc" 		=> "",
						"id" 		=> "zon_option_bread_error",
						"std" 		=> "Error 404",
						"type" 		=> "text"
				);
//end breadcrumb setting

$of_options[] = array( 	"name" 		=> "Footer Settings",
						"type" 		=> "heading"
				);
$of_options[] = array( 	"name" 		=> "Select number column widget footer",
						"desc" 		=> "",
						"id" 		=> "zon_option_footer_column",
						"std" 		=> "4",
						"type" 		=> "select",
						"options" 	=> array('1','2','3','4')
				);


$of_options[] = array( 	"name" 		=> "Styling Options",
						"type" 		=> "heading"
				);
				
$of_options[] = array( 	"name" 		=> "Theme Stylesheet",
						"desc" 		=> "Select your themes alternative color scheme.",
						"id" 		=> "alt_stylesheet",
						"std" 		=> "default.css",
						"type" 		=> "select",
						"options" 	=> $alt_stylesheets
				);
				
$of_options[] = array( 	"name" 		=> "Body Background Color",
						"desc" 		=> "Pick a background color for the theme (default: #fff).",
						"id" 		=> "body_background",
						"std" 		=> "",
						"type" 		=> "color"
				);
				
$of_options[] = array( 	"name" 		=> "Header Background Color",
						"desc" 		=> "Pick a background color for the header (default: #fff).",
						"id" 		=> "header_background",
						"std" 		=> "",
						"type" 		=> "color"
				);
				
$of_options[] = array( 	"name" 		=> "Footer Background Color",
						"desc" 		=> "Pick a background color for the footer (default: #fff).",
						"id" 		=> "footer_background",
						"std" 		=> "",
						"type" 		=> "color"
				);
				
$of_options[] = array( 	"name" 		=> "Body Font",
						"desc" 		=> "Specify the body font properties",
						"id" 		=> "body_font",
						"std" 		=> array('size' => '12px','face' => 'arial','style' => 'normal','color' => '#000000'),
						"type" 		=> "typography"
				);  
				
$of_options[] = array( 	"name" 		=> "Custom CSS",
						"desc" 		=> "Quickly add some CSS to your theme by adding it to this block.",
						"id" 		=> "custom_css",
						"std" 		=> "",
						"type" 		=> "textarea"
				);
				
$of_options[] = array( 	"name" 		=> "Example Options",
						"type" 		=> "heading"
				);
				
$of_options[] = array( 	"name" 		=> "Typography",
						"desc" 		=> "This is a typographic specific option.",
						"id" 		=> "typography",
						"std" 		=> array(
											'size'  => '12px',
											'face'  => 'verdana',
											'style' => 'bold italic',
											'color' => '#123456'
										),
						"type" 		=> "typography"
				);  
				
$of_options[] = array( 	"name" 		=> "Border",
						"desc" 		=> "This is a border specific option.",
						"id" 		=> "border",
						"std" 		=> array(
											'width' => '2',
											'style' => 'dotted',
											'color' => '#444444'
										),
						"type" 		=> "border"
				);
				
$of_options[] = array( 	"name" 		=> "Colorpicker",
						"desc" 		=> "No color selected.",
						"id" 		=> "example_colorpicker",
						"std" 		=> "",
						"type" 		=> "color"
					); 
					
$of_options[] = array( 	"name" 		=> "Colorpicker (default #2098a8)",
						"desc" 		=> "Color selected.",
						"id" 		=> "example_colorpicker_2",
						"std" 		=> "#2098a8",
						"type" 		=> "color"
				);

$of_options[] = array( 	"name" 		=> "Input Text",
						"desc" 		=> "A text input field.",
						"id" 		=> "test_text",
						"std" 		=> "Default Value",
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Input Checkbox (false)",
						"desc" 		=> "Example checkbox with false selected.",
						"id" 		=> "example_checkbox_false",
						"std" 		=> 0,
						"type" 		=> "checkbox"
				);
				
$of_options[] = array( 	"name" 		=> "Input Checkbox (true)",
						"desc" 		=> "Example checkbox with true selected.",
						"id" 		=> "example_checkbox_true",
						"std" 		=> 1,
						"type" 		=> "checkbox"
				);
				
$of_options[] = array( 	"name" 		=> "Normal Select",
						"desc" 		=> "Normal Select Box.",
						"id" 		=> "example_select",
						"std" 		=> "three",
						"type" 		=> "select",
						"options" 	=> $of_options_select
				);
				
$of_options[] = array( 	"name" 		=> "Mini Select",
						"desc" 		=> "A mini select box.",
						"id" 		=> "example_select_2",
						"std" 		=> "two",
						"type" 		=> "select",
						"mod" 		=> "mini",
						"options" 	=> $of_options_radio
				); 
				
$of_options[] = array( 	"name" 		=> "Google Font Select",
						"desc" 		=> "Some description. Note that this is a custom text added added from options file.",
						"id" 		=> "g_select",
						"std" 		=> "Select a font",
						"type" 		=> "select_google_font",
						"preview" 	=> array(
										"text" => "This is my preview text!", //this is the text from preview box
										"size" => "30px" //this is the text size from preview box
						),
						"options" 	=> array(
										"none" => "Select a font",//please, always use this key: "none"
										"Lato" => "Lato",
										"Loved by the King" => "Loved By the King",
										"Tangerine" => "Tangerine",
										"Terminal Dosis" => "Terminal Dosis"
						)
				);
				
$of_options[] = array( 	"name" 		=> "Google Font Select2",
						"desc" 		=> "Some description.",
						"id" 		=> "g_select2",
						"std" 		=> "Select a font",
						"type" 		=> "select_google_font",
						"options" 	=> array(
										"none" => "Select a font",//please, always use this key: "none"
										"Lato" => "Lato",
										"Loved by the King" => "Loved By the King",
										"Tangerine" => "Tangerine",
										"Terminal Dosis" => "Terminal Dosis"
									)
				);
				
$of_options[] = array( 	"name" 		=> "Input Radio (one)",
						"desc" 		=> "Radio select with default of 'one'.",
						"id" 		=> "example_radio",
						"std" 		=> "one",
						"type" 		=> "radio",
						"options" 	=> $of_options_radio
				);
				
$url =  ADMIN_DIR . 'assets/images/';
$of_options[] = array( 	"name" 		=> "Image Select",
						"desc" 		=> "Use radio buttons as images.",
						"id" 		=> "images",
						"std" 		=> "warning.css",
						"type" 		=> "images",
						"options" 	=> array(
											'warning.css' 	=> $url . 'warning.png',
											'accept.css' 	=> $url . 'accept.png',
											'wrench.css' 	=> $url . 'wrench.png'
										)
				);
				
$of_options[] = array( 	"name" 		=> "Textarea",
						"desc" 		=> "Textarea description.",
						"id" 		=> "example_textarea",
						"std" 		=> "Default Text",
						"type" 		=> "textarea"
				);
				
$of_options[] = array( 	"name" 		=> "Multicheck",
						"desc" 		=> "Multicheck description.",
						"id" 		=> "example_multicheck",
						"std" 		=> array("three","two"),
						"type" 		=> "multicheck",
						"options" 	=> $of_options_radio
				);
				
$of_options[] = array( 	"name" 		=> "Select a Category",
						"desc" 		=> "A list of all the categories being used on the site.",
						"id" 		=> "example_category",
						"std" 		=> "Select a category:",
						"type" 		=> "select",
						"options" 	=> $of_categories
				);
				
//Advanced Settings
$of_options[] = array( 	"name" 		=> "Advanced Settings",
						"type" 		=> "heading"
				);
				
$of_options[] = array( 	"name" 		=> "Folding Checkbox",
						"desc" 		=> "This checkbox will hide/show a couple of options group. Try it out!",
						"id" 		=> "offline",
						"std" 		=> 0,
						"folds" 	=> 1,
						"type" 		=> "checkbox"
				);
				
$of_options[] = array( 	"name" 		=> "Hidden option 1",
						"desc" 		=> "This is a sample hidden option 1",
						"id" 		=> "hidden_option_1",
						"std" 		=> "Hi, I\'m just a text input",
						"fold" 		=> "offline", /* the checkbox hook */
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Hidden option 2",
						"desc" 		=> "This is a sample hidden option 2",
						"id" 		=> "hidden_option_2",
						"std" 		=> "Hi, I\'m just a text input",
						"fold" 		=> "offline", /* the checkbox hook */
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Hello there!",
						"desc" 		=> "",
						"id" 		=> "introduction_2",
						"std" 		=> "<h3 style=\"margin: 0 0 10px;\">Grouped Options.</h3>
						You can group a bunch of options under a single heading by removing the 'name' value from the options array except for the first option in the group.",
						"icon" 		=> true,
						"type" 		=> "info"
				);
				
				$of_options[] = array( 	"name" 		=> "Some pretty colors for you",
										"desc" 		=> "Color 1.",
										"id" 		=> "example_colorpicker_3",
										"std" 		=> "#2098a8",
										"type" 		=> "color"
								);
								
				$of_options[] = array( 	"name" 		=> "",
										"desc" 		=> "Color 2.",
										"id" 		=> "example_colorpicker_4",
										"std" 		=> "#2098a8",
										"type" 		=> "color"
								);
								
				$of_options[] = array( 	"name" 		=> "",
										"desc" 		=> "Color 3.",
										"id" 		=> "example_colorpicker_5",
										"std" 		=> "#2098a8",
										"type" 		=> "color"
								);
								
				$of_options[] = array( 	"name" 		=> "",
										"desc" 		=> "Color 4.",
										"id" 		=> "example_colorpicker_6",
										"std" 		=> "#2098a8",
										"type" 		=> "color"
								);
				
// Backup Options
$of_options[] = array( 	"name" 		=> "Backup Options",
						"type" 		=> "heading",
						"icon"		=> ADMIN_IMAGES . "icon-slider.png"
				);
				
$of_options[] = array( 	"name" 		=> "Backup and Restore Options",
						"id" 		=> "of_backup",
						"std" 		=> "",
						"type" 		=> "backup",
						"desc" 		=> 'You can use the two buttons below to backup your current options, and then restore it back at a later time. This is useful if you want to experiment on the options but would like to keep the old settings in case you need it back.',
				);
				
$of_options[] = array( 	"name" 		=> "Transfer Theme Options Data",
						"id" 		=> "of_transfer",
						"std" 		=> "",
						"type" 		=> "transfer",
						"desc" 		=> 'You can tranfer the saved options data between different installs by copying the text inside the text box. To import data from another install, replace the data in the text box with the one from another install and click "Import Options".',
				);
				
	}//End function: of_options()
}//End chack if function exists: of_options()
?>
